#ifndef __dummy_events_dispatcher_hpp__
#define __dummy_events_dispatcher_hpp__

#pragma once

#include "../include/fluxio_proto.hpp"

///////////////////////////////////////////////////////////////////////////////

class dummy_events_dispatcher : private boost::noncopyable
{
public:
	dummy_events_dispatcher(boost::asio::io_service& io_service) 
		: timer_(io_service),timeout_(15)
	{
		timer_.expires_from_now(boost::posix_time::seconds(timeout_));
		timer_.async_wait(boost::bind(&dummy_events_dispatcher::handle_event,this,boost::asio::placeholders::error));
	}
public:
	void stop()
	{
		timer_.cancel();
	}
private:
	void handle_event(boost::system::error_code& error)
	{
		if (error)
		{
			return;
		}

		fluxio::var_manager_ptr->OnChangeVarValue();

		timer_.expires_from_now(boost::posix_time::seconds(timeout_));
		timer_.async_wait(boost::bind(&dummy_events_dispatcher::handle_event,this,boost::asio::placeholders::error));
	}
private:
	boost::asio::deadline_timer				timer_;
	long									timeout_;				// in second
};

#endif
